package com.sjqi.demo.builer;

import com.sjqi.demo.config.Configuration;
import org.dom4j.Element;

import java.util.List;

/**
 * @author qishaojun
 * 专门解析映射文件
 */
public class XMLMapperBuilder {
    private Configuration configuration;

    public XMLMapperBuilder(Configuration configuration) {
        this.configuration = configuration;
    }

    public void parseMapper(Element mapperRoot) {
        String namespace = mapperRoot.attributeValue("namespace");
        //TODO:补充增删改查
        List<Element> selectElementList = mapperRoot.elements("select");
        for (Element selectElement : selectElementList) {
            XMLStatementBuilder statementBuilder = new XMLStatementBuilder(configuration);
            statementBuilder.parseStatementElement(selectElement, namespace);
        }

    }
}
